<?php
// $Id: views-view-unformatted.tpl.php,v 1.6 2008/10/01 20:52:11 merlinofchaos Exp $
/**
 * @file views-view-unformatted.tpl.php
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php 
		print '<pre>';
		//print_r(get_defined_vars());
		//print_r($rows);
		print '</pre>';
	if ($view->name === "vacancy_list")
	{
		//print "<table>";
		$general_vacancy = array();
		$internal_vacancy = array();
		$i = 0;		
		foreach ($rows as $id => $row)
		{
			if (strpos($row, "Общий конкурс") !== false)
			{
				$general_vacancy[] = $row;
			} else {
				$internal_vacancy[] = $row;
			}
		}
		$outstr = "<table><tr><td><h2>Общий конкурс</h2></td><td><h2>Внутренний конкурс</h2></td></tr>";
		$length_gen = count($general_vacancy);
		$length_int = count($internal_vacancy);
		$length_max = $length_gen;
		if ($length_int > $length_max)
		{
			$length_max = $length_int;
		}
		for ($i = 0; $i < $length_max; $i++)
		{
			if ($i < $length_int && $i < $length_gen)
				$outstr .= "<tr><td>" . $general_vacancy[$i] . "</td><td>" . $internal_vacancy[$i] . "</td></tr>";
			else
			if ($i < $length_int && $i >= $length_gen)
				$outstr .= "<tr><td></td><td>" . $internal_vacancy[$i] . "</td></tr>";
			else
			if ($i >= $length_int && $i < $length_gen)
				$outstr .= "<tr><td>" . $general_vacancy[$i] . "</td><td></td></tr>";
		} 
		$outstr .= "</table>";
		print($outstr);
	} else 
	if ($view->name === "news_list")
	{
		$i = 0;
		print "<table>";
		foreach ($rows as $id => $row)
		{
			if ($i == 0)
			{
				print "<tr>";
			}
			print "<td valign='top' width='50%'><div class=\"$classes[$id]\">$row</div></td>";
			$i++;
			if ($i == 2)
			{
				print "</tr>";
				$i = 0;
			}
		}
		print "</table>";
	} else 	
	{
		$i = 0;
		print "<table>";
		foreach ($rows as $id => $row)
		{
			if ($i == 0)
			{
				print "<tr>";
			}
			print "<td valign='top' width='50%'><div class=\"$classes[$id]\">$row</div></td>";
			$i++;
			if ($i == 2)
			{
				print "</tr>";
				$i = 0;
			}
		}
		print "</table>";
	}
?>
